<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">

    <script type="text/javascript" src="http://tson.com/steemjs/steem.min.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>

    <script>
        var localDiscussion = null;
        var index = -1;

        $(document).ready(function () {
			steem.api.setWebSocket("wss://steemd.steemitstage.com");
			 
			$("#btnGetComments").click(function () {
				/** Broadcast a post */
                //如果permlink对话框里面已经有了，则用对话框
                var permlink = $("#steemit_tools_permalink").val();
                //这里可能会出现问题1、中文问题。2、是空问题，3、重复问题
                var username = $("#txtAuthor").val();
                var tags = $("#steemit_tools_tags").val().split(' ');
                //检查tags的对错
                var mainTag = tags[0];
                var title = $("#title").val();
                var body = $("#body").val();
                var postingWif = $("#wif").val();
                //var body = $("#tinymce").val();
                steem.broadcast.comment(
                    postingWif,
                    '', // Leave parent author empty
                    mainTag, // Main tag
                    username, // Author
                    permlink, // Permlink
                    title, // Title
                    body, // Body
                    { tags: [ tags[1],tags[2],tags[3],tags[4] ] }, 
                    // 可以直接这样输入，因为在js中，如果没有tags[4]，直接为null，超过4的直接忽略
                    function(err, result) {
                        //console.log(err, result);
                        if(!err)
                        {
                            //成功
                            //return true;
                            console.log("success");
                        }
                });	
			});
		});
    </script>
</head>
<body>
    <hr />

    <div class="expandablerVotes">
        <div>
            Author
            <input type="text" id="txtAuthor" style="width: 150px;" value="wpcomments" /> &nbsp;&nbsp;
            wif
            <input type="text" id="wif" style="width: 150px;" value="my wif" /> &nbsp;&nbsp;
            Title
            <input type="text" id="title" style="width: 150px;" value="example title" /> &nbsp;&nbsp;
            body
            <input type="text" id="body" style="width: 150px;" value="example body" /> &nbsp;&nbsp;
            Tags
            <input type="text" id="steemit_tools_tags" style="width: 150px;" value="test test1 test2 test3" /> &nbsp;&nbsp;
            Link
            <input type="text" id="steemit_tools_permalink" style="width: 150px;" value="test-test1" /> &nbsp;&nbsp;
			<input id="btnGetComments" type="button" value="Get Comments Data" />
        </div>
		<br/>
    </div>
	<br/>
	<div id="resultsTable">
	</div>
</body>
</html>
